﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace ZMHWcfServiceLibrary
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码和配置文件中的类名“WCFPerCallSVC”。
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    //[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]  
    public class WCFSessionSVC : IWCFSessionSVC, IDisposable
    {
        int m_Counter = 0;
        public WCFSessionSVC()
        {
            Trace.WriteLine(OperationContext.Current?.SessionId);
            Trace.WriteLine("WCFPerCallSVC!");
        } 
        public void MyMethod()
        {
            m_Counter++;
            Trace.WriteLine("Counter = " + m_Counter);
        }  
        public void Dispose()
        {
            Trace.WriteLine(OperationContext.Current?.SessionId);
            Trace.WriteLine("Displose!");
        }
    }
}
